﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.DrugTrade.Model.Enum;

namespace HZ.DrugTrade.Web.Hospitals.Collection
{
    public partial class HistroyTradeRecord : BasePage
    {
        public HistroyTradeRecord()
        {
            this.ModuleNo = Module.结算单管理.ToString();
        }

        IBLL.IBLL_Purchase ip = BLLFactory.Factory.BLL_Purchase();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        /// <summary>
        /// 获取有过交易记录的企业
        /// </summary>
        private void BindData()
        {
            //获取条件
            string companyName = txtCompanyName.Text.Trim().Replace("'", "");

            try
            {
                int totalCount = 0;
                //AspNetPager1.PageSize = Constants.GRIDVIEW_PAGE_SIZE;
                System.Data.DataTable dt = ip.GetHistroyTradeCompany(CurrentAccount.GetUser().Org.OrgID, companyName, "", AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, out totalCount);
                AspNetPager1.RecordCount = totalCount;
                gvwHistroyList.DataSource = dt;
                gvwHistroyList.DataBind();
            }
            catch
            {
                HZ.Web.WebUtil.Alert("页面错误！", this);
            }
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnQuery_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
            BindData();
        }

        /// <summary>
        /// 翻页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            BindData();
        }
    }
}
